var loginValidator;

var modelObject = {
	init:function(){
		//表单验证
		loginValidator = $("#loginForm").validate
		({
			rules: {
				loginId: {
					required:true,
					digits:true
				},
				loginPwd: "required"
			},
			messages:{
				loginId:{
					required:"请填写用户名",
					digits:"用户名不正确"
				},
				loginPwd:"请填写密码"
			},
			submitHandler:function(form){
				form.submit();
			}
		});
	}
};

$(document).ready(function(){
	modelObject.init();
	
	//登录失败
	if(!!loginStatus && loginStatus =="0"){
		if(!!loginMsg){
			if(loginMsg == "Name or password error."){
				$("#loginMsgDiv").show("fast",function(){      
					$(".error").text("用户名或密码错误");    
				});
			}else if(loginMsg == "User doesn't exist."){
				$("#loginMsgDiv").show("fast",function(){      
					$(".error").text("用户不存在");    
				});	
			}
		}
	}
	
	$("#loginId").on("focus",function(){
		$("#loginMsgDiv").hide();
	});
});